#include "SharedVariables.fxh"

float4x4 World;

struct LinearDepthVSInput
{
    float4 Position : POSITION0;
};

struct LinearDepthVSOutput
{
    float4 Position : POSITION0;
    float2 Depth : TEXCOORD0;
};

LinearDepthVSOutput LinearDepthVSFunction(LinearDepthVSInput input)
{
    LinearDepthVSOutput output;

    float4 worldPosition = mul(input.Position, World);
    output.Position = mul(worldPosition, ViewProj);
    output.Depth = output.Position.zw;

    return output;
}

float4 LinearDepthPSFunction(LinearDepthVSOutput input) : COLOR0
{
	return float4(input.Depth.x / input.Depth.y, 0.0f, 0.0f, 1.0f);
}

technique LinearDepth
{
    pass Pass1
    {
        VertexShader = compile vs_2_0 LinearDepthVSFunction();
        PixelShader = compile ps_2_0 LinearDepthPSFunction();
    }
}